package entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * Klasa Appointment povezuje entitet APPOINTMENT u bazi podataka i sinhronizuje
 * 
 * @author rigo
 * 
 */
@Entity
@Table(name="APPOINTMENT")
public class Appointment implements Serializable{
	private static final long serialVersionUID = -2978412220354765026L;

	@Id 
	@GeneratedValue(strategy=IDENTITY)
	@Column(name="AP_ID", unique=true, nullable=false)
	protected Integer appointmentId;

	@OneToOne(optional=true, mappedBy="appointment")
	protected FootballMatch footballMatch;
	
	@Column(name="AP_LOCATION", unique=true, nullable=false)
	protected String location;
	
	@Column(name="AP_DATE", unique=false, nullable=false)
	protected Date date;
	
	@Column(name="AP_FROM", unique=false, nullable=false)
	protected Time from;

	@Column(name="AP_TO", unique=false, nullable=false)
	protected Time to;
	
	@Column(name="AP_EXPIRED", unique=false, nullable=true)
	protected Boolean expired;
	
	@Column(name="AP_DELETED", unique=false, nullable=true)
	protected Boolean deleted;
	
	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="appointment")
	protected Set<Comment> comment = new HashSet<Comment>();

	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="appointment")
	protected Set<Players> players = new HashSet<Players>();
	
	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public Integer getAppointmentId() {
		return appointmentId;
	}

	public void setAppointmentId(Integer appointmentId) {
		this.appointmentId = appointmentId;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Time getFrom() {
		return from;
	}

	public void setFrom(Time from) {
		this.from = from;
	}

	public Time getTo() {
		return to;
	}

	public void setTo(Time to) {
		this.to = to;
	}

	public Boolean getExpired() {
		return expired;
	}

	public void setExpired(Boolean expired) {
		this.expired = expired;
	}

	public Set<Comment> getComment() {
		return comment;
	}

	public void setComment(Set<Comment> comment) {
		this.comment = comment;
	}

	public FootballMatch getFootballMatch() {
		return footballMatch;
	}

	public Set<Players> getPlayers() {
		return players;
	}

	public void setFootballMatch(FootballMatch footballMatch) {
		this.footballMatch = footballMatch;
	}

	public void setPlayers(Set<Players> players) {
		this.players = players;
	}

	
}
